//引入两个核心函数
import { createRouter, createWebHashHistory } from 'vue-router'
//定义路由规则数组
const routes = [
    //登录页面
    {
        path: '/',
        name: 'login',
        component: () => import('@/pages/login.vue')
    },
    //注册页面
    {
        path: '/register',
        name: 'register',
        component: () => import('@/pages/register.vue')
    },
       // 修改密码页面
       {
        path: '/managerInfo',
        name: 'managerInfo',
        component: () => import('@/pages/role/managerInfo.vue')
    },
    //后台管理页面
    {
        path: '/index',
        name: 'index',
        redirect: '/employment/major',
        component: () => import('@/pages/index/index.vue'),
        //子路由
        children: [
            //角色管理页面
            {
                path: '/role/role',
                name: 'role',
                component: () => import('@/pages/role/role.vue')
            },
            // 权限管理页面
            {
                path: '/role/permission',
                name: 'permission',
                component: () => import('@/pages/role/permission.vue')
            },
            // 方向管理页面
            {
                path: '/role/major',
                name: 'major',
                component: () => import('@/pages/role/major.vue')
            },
             // 员工管理页面
             {
                path: '/role/staff',
                name: 'staff',
                component: () => import('@/pages/role/staff.vue')
            },
            // 班级管理页面
            {
                path: '/clazz/clazz',
                name: 'clazz',
                component: () => import('@/pages/clazz/clazz.vue')
            },
            {
                path: '/clazz/clazzDetail',
                name: 'employmentDetails',
                component: () => import('@/pages/clazz/clazzEStu.vue')
            },
            {
                path: '/clazz/clazzStudent',
                name: 'clazzStudent',
                component: () => import('@/pages/clazz/clazzStudent.vue')
            },
            // 企业管理页面
            {
                path: '/enterprise/enterprise',
                name: 'enterprise',
                component: () => import('@/pages/enterprise/list.vue')

            },
            {
                path: '/enterprise/job',
                name: 'enterpriseJob',
                component: () => import('@/pages/enterprise/job.vue')
            },
        
            //学生就业管理页面
            {
                path: '/employment/employment',
                name: 'employment',
                component: () => import('@/pages/employment/employment.vue')
            },
             //项目经理就业统计
             {
                path: '/employment/manager',
                name: 'employmentManager',
                component: () => import('@/pages/employment/manager.vue')
            },
              //就业方向统计
              {
                path: '/employment/major',
                name: 'employmentMajor',
                component: () => import('@/pages/employment/major.vue')
            },
            //学生管理页面
            {
                path: '/student/index',
                name: 'student',
                component: () => import('@/pages/student/student.vue')
            },
            //简历页面
            {
                path: '/student/resume',
                name: 'resume',
                component: () => import('@/pages/student/resume.vue')
            },
             //简历中心页面
            {
                path: '/student/stuResume',
                name: 'stu_resume',
                component: () => import('@/pages/student/stuResume.vue')
            },
            // 学生就业详细页面
            {
                path: '/student/stuResDetail',
                name: 'stu_res_detail',
                component: () => import('@/pages/student/stuResDetail.vue')
            },
            {
                path: '/enterprise/entEmp',
                name: 'entEmp',
                component: () => import('@/pages/enterprise/entEmp.vue')
            },
            {
                path: '/enterprise/entJob',
                name: 'entJob',
                component: () => import('@/pages/enterprise/entJob.vue')
            },
        ],

    },


]


//加载了访问历史记录的函数
//应用路由规则
const router = createRouter({
    history: createWebHashHistory(),
    routes,
})

// 设置全局前置守卫   拦截/index，替换为coupon   
// 或者直接使用路由重定向 redirect: '/coupon'
/* router.beforeEach((to, from, next) => {
    if (to.path === '/index') {
        next('/coupon'); // 重定向到 /coupon
    } else {
        next(); // 正常跳转
    }
}); */

//导出路由
export default router